package com.bestcem.xm.award.mq.receiver.biz;

import com.bestcem.xm.award.mq.dto.*;
import com.bestcem.xm.award.service.AwardMqHandler;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.support.GenericMessage;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class ReceiverService {

    private AwardMqHandler awardMqHandler;

    @Autowired
    public void setAwardMqHandler(AwardMqHandler awardMqHandler) {
        this.awardMqHandler = awardMqHandler;
    }

    /**
     * 延迟消息:开始抽奖奖励消息
     */
    public void awardDrawStart(GenericMessage<DrawAwardStartDTO> message) {
        DrawAwardStartDTO dto = message.getPayload();
        if (log.isInfoEnabled()) {
            log.info("[award] 奖励异步消费抽奖开始消息 {}", dto);
        }
        awardMqHandler.startDrawAward(dto);
    }

    /**
     * 延迟消息:奖励通知抽奖结束
     */
    public void awardDrawStop(GenericMessage<DrawAwardStopDTO> message) {
        DrawAwardStopDTO dto = message.getPayload();
        if (log.isInfoEnabled()) {
            log.info("[award] 奖励异步消费抽奖结束消息 {}", dto);
        }
        awardMqHandler.stopDrawAward(dto);
    }

    /**
     * 延迟消息:奖励异步消费清理临时表通知消息
     */
    public void awardTempClean(GenericMessage<TempCleanDTO> message) {
        TempCleanDTO dto = message.getPayload();
        if (log.isInfoEnabled()) {
            log.info("[award] 奖励异步消费清理临时表通知消息 {}", dto);
        }
        awardMqHandler.cleanAwardTempByTempId(dto);
    }

    /**
     * 延迟消息:奖励消费红包开始消息
     */
    public void awardRedPacketStart(GenericMessage<RedPacketAwardStartDTO> message) {
        RedPacketAwardStartDTO dto = message.getPayload();
        if (log.isInfoEnabled()) {
            log.info("[award] 奖励消费红包开始消息 {}", dto);
        }
        awardMqHandler.startRedPacketAward(dto);
    }

    /**
     * 延迟消息:奖励消费红包结束消息
     */
    public void awardRedPacketStop(GenericMessage<RedPacketAwardStopDTO> message) {
        RedPacketAwardStopDTO dto = message.getPayload();
        if (log.isInfoEnabled()) {
            log.info("[award] 奖励消费红包结束消息 {}", dto);
        }
        awardMqHandler.stopRedPacketAward(dto);
    }

    /**
     * 延迟消息:励消费查询红包发放结果消息
     */
    public void awardRedPacketSending(GenericMessage<RedPacketAwardSendingDTO> message) {
        RedPacketAwardSendingDTO dto = message.getPayload();
        if (log.isInfoEnabled()) {
            log.info("[award] 奖励消费查询红包发放结果消息 {}", dto);
        }
        awardMqHandler.sendingRedPacketAward(dto);
    }

    /**
     * 延迟消息:奖励消费奖励开始消息
     */
    public void awardAwardStart(GenericMessage<AwardStartDTO> message) {
        AwardStartDTO dto = message.getPayload();
        if (log.isInfoEnabled()) {
            log.info("[award] 奖励消费奖励开始消息 {}", dto);
        }
        awardMqHandler.startAward(dto);
    }

    /**
     * 延迟消息:奖励消费奖励结束消息
     */
    public void awardAwardStop(GenericMessage<AwardStopDTO> message) {
        AwardStopDTO dto = message.getPayload();
        if (log.isInfoEnabled()) {
            log.info("[award] 奖励消费奖励结束消息 {}", dto);
        }
        awardMqHandler.stopAward(dto);
    }

    /**
     * 奖励消费项目删除消息
     */
    public void awardProjectDelete(GenericMessage<ProjectDeleteDTO> message) {
        ProjectDeleteDTO dto = message.getPayload();
        if (log.isInfoEnabled()) {
            log.info("[award] 奖励消费项目删除消息 {}", dto);
        }
        awardMqHandler.deleteProject(dto);
    }

    /**
     * 奖励消费中奖短信通知消息
     */
    public void awardDrawSms(GenericMessage<DrawAwardSendSmsDTO> message) {
        DrawAwardSendSmsDTO dto = message.getPayload();
        if (log.isInfoEnabled()) {
            log.info("[award] 奖励消费中奖短信通知消息 {}", dto);
        }
        awardMqHandler.sendDrawAwardSms(dto);
    }
}
